package com.luyuan.crm.question.web.provider;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import com.luyuan.crm.question.model.Question;
import com.luyuan.crm.question.service.QuestionService;
import com.ruijie.web.jsf.provider.AbstractSelectItemsProviderAdapter;

@Component("questionProvider")
public class QuestionProvider extends AbstractSelectItemsProviderAdapter implements Serializable {

    private static final long serialVersionUID = 1L;

    @Resource(name = "questionService")
    private QuestionService questionService;

    @Override
    protected void populateSelectItems(List<SelectItem> list, Object... params) {
        List<Question> questions = questionService.getAll();
        for (Question model : questions) {
            SelectItem item = new SelectItem(model, model.getQuestionName());
            list.add(item);
        }
    }

}
